import { cateadd, catedelete, cateedit, cateinfo, catelist } from "../../utils/request/api.js";
export default {
    catelist_a({ commit }, payload) {
        catelist(payload).then(res => {
            if (res.code == 200 && res.list) {
                 commit('setcatelist',res.list)
            }
        })
    },
    cateadd_a({ commit }, payload) {
        cateadd(payload).then(res => {
             commit('setcateTitle', res)
        })
    },
    catedelete_a({ commit }, payload) {
        catedelete(payload).then(res => {
            //把操作成功变成删除成功
            if (res.code == 200) {
                commit('setcateTitle', {...res,msg:"删除成功"})
            }
        })
    },
    cateinfo_a({ commit }, payload) {
        cateinfo(payload).then(res => {
            //点击编辑的时候 直接把id添加到cateinfo上
             commit('setcateinfo',{...res.list,id:payload})
        })
    },
    cateedit_a({ commit }, payload) {
        cateedit(payload).then(res => {
            //把操作成功变成修改成功
            commit('setcateTitle',{...res,msg:"修改成功"})
        })
    },
}